package testSqlSelect;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
 
public class testSqlSelect {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stm = null;
        ResultSet rs = null;
 
        try {
            conn = Util.getConn();
            String sql = "SELECT * FROM users";
            stm = conn.createStatement();
            rs = stm.executeQuery(sql);
            System.out.println("查询结果：");
            
            while (rs.next()) {
                String name = rs.getString("username");
                System.out.println("Name:" + name);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            Util.close(conn, stm, rs);
        }
 
    }
}
